<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<label><input id="year" type="text" value="" name="">年</label>
	<label><input id="month" type="text" value="" name="">月</label>
	<label><input id="day" type="text" value="" name="">日</label>
	<input id="btn" type="button" value="计算" name="">
</body>
<script type="text/javascript">
	var year=document.getElementById("year");
	var month=document.getElementById("month");
	var day=document.getElementById("day");
	var btn=document.getElementById("btn");
	btn.onclick=function(){
		var y=Number(year.value);
		var m=Number(month.value);
		var d=Number(day.value);
		var allDay=0;
		switch(m){
			case 12:
				allDay+=30;
			case 11:
				allDay+=31;
			case 10:
				allDay+=30;
			case 9:
				allDay+=31;
			case 8:
				allDay+=31;
			case 7:
				allDay+=30;
			case 6:
				allDay+=31;
			case 5:
				allDay+=30;
			case 4:
				allDay+=31;
			case 3:
				allDay+=28;
			case 2:
				allDay+=31;
			case 1:
				allDay+=d;
		}
		console.log(allDay);
		if (y%4==0&&y%100!=0||y%400==0) {
			if (m>=3) {
				allDay+=1;
			}
			document.write("该日期为一年中的第"+allDay+"天");
		}else{
			document.write("该日期为一年中的第"+allDay+"天");
		}
	}
</script>
</html>